#-*-coding:utf-8-*-
import unittest,random,sys
from time import sleep
from selenium.webdriver.common.by import By
from DriverAndUnit import myunit,myfunction
from LbtFront.Base.LoginPage import login
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

class welcome(myunit.myTest):
    '''首页验证'''
    def test_welcome(self):
        '''首页'''
        try:
            login(self.driver).open()
            getInfo = self.driver.find_element_by_class_name('dierkuai-left-p2')
            self.assertIn('乐贝通是河南宇信科技有限公司旗下的专属幼教行业的新兴业务产品', getInfo.text)
            myfunction.insert_img(self.driver, 'test_welcome.png')
        finally:
            errorPng = "FinallyPng_" + myfunction.getCurrentTime() + ".png"
            myfunction.insert_img(self.driver, errorPng)
    def test_functionDes(self):
        '''功能介绍'''
        try:
            login(self.driver).open()
            self.driver.find_element_by_link_text('功能介绍').click()
            getInfo2 = self.driver.find_elements_by_id('duanluo1')
            myfunction.insert_img(self.driver, 'test_functionDes.png')
            self.assertEqual(len(getInfo2), 1)
        finally:
            errorPng = "FinallyPng_" + myfunction.getCurrentTime() + ".png"
            myfunction.insert_img(self.driver, errorPng)
    def test_askUse(self):
        '''申请使用'''
        try:
            login(self.driver).open()
            self.driver.find_element_by_link_text('申请使用').click()
            sleep(2)
            text = self.driver.find_elements_by_id('btn_getNum1')
            myfunction.insert_img(self.driver, 'test_askUse.png')
            self.assertEqual(len(text), 1)
        finally:
            errorPng = "FinallyPng_" + myfunction.getCurrentTime() + ".png"
            myfunction.insert_img(self.driver, errorPng)
    def test_joinUs(self):
        '''加盟合作'''
        try:
            login(self.driver).open()
            self.driver.find_element_by_link_text('加盟合作').click()
            infoGet = self.driver.find_elements_by_class_name('jmhz-content')
            myfunction.insert_img(self.driver, 'test_joinUs.png')
            self.assertEqual(len(infoGet), 1)
        finally:
            errorPng = "FinallyPng_" + myfunction.getCurrentTime() + ".png"
            myfunction.insert_img(self.driver, errorPng)
    def test_aboutUs(self):
        '''关于我们'''
        try:
            login(self.driver).open()
            self.driver.find_element_by_link_text('关于我们').click()
            getInfo = self.driver.find_element_by_class_name('guanyulebeitong-p1')
            myfunction.insert_img(self.driver, 'test_aboutUs.png')
            self.assertEqual(getInfo.text, '关于乐贝通')
        finally:
            errorPng = "FinallyPng_" + myfunction.getCurrentTime() + ".png"
            myfunction.insert_img(self.driver, errorPng)
if __name__=='__main__':
    unittest.main()